/**
 * 
 */
package algorithm.sort;

/**
 * 冒泡排序.
 * @author LionBule
 *
 */
public class BubbleSort {

	public static void main(String[] args) {
		int[] data = new int[]{11,-2,36,8,9,43,26,24,99};
		
		print(data);
		for(int i=1;i<data.length;i++){
			for(int j=0;j<data.length;j++){
				if(data[i]>data[j]){
					swap(data, i, j);
				}
			}
		}
		print(data);
	}
	
	static void print(int[] data){
		for(int i=0;i<data.length;i++){
			System.out.print(data[i]+", ");
		}
		System.out.println();
	}
	
    static void swap(int[] data, int x, int y) {  
        int temp = data[x];  
        data[x] = data[y];  
        data[y] = temp;  
    }  
}
